package com.isoftstone.wms.common;

import lombok.Data;

@Data
public class Result {
    private int code;
    private String msg;
    private Long total;
    private Object data;

    private static Result result(int code, String msg, Long total, Object data) {
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        result.setTotal(total);
        result.setData(data);
        return result;
    }

    public static Result success() {
        return result(200, "操作成功", null,null);
    }

    public static Result success(Object data) {
        return result(200, "操作成功", null, data);
    }

    public static Result success(Object data, String msg) {
        return result(200, msg, null, data);
    }

    public static Result success(Object data, Long total) {
        return result(200, "操作成功", total, data);
    }

    //失败
    public static Result fail() {
        return result(400, "失败", 0L, null);
    }

    //失败
    public static Result fail(String msg) {
        return result(400, msg, 0L, null);
    }
}
